﻿#include "gratingsettingwid.h"
#include "ui_gratingsettingwid.h"

GratingSettingWid::GratingSettingWid(QWidget *parent)
	: QWidget(parent)
	, ui(new Ui::GratingSettingWid())
{
	ui->setupUi(this);
	setStyleSheet("font: 12pt \"Agency FB\"");
}

GratingSettingWid::~GratingSettingWid()
{
	delete ui;
}


void GratingSettingWid::Init(const GratingJ& cfg)
{
	ui->lineEdit->setText(cfg.id());
	ui->spinBox->setValue(cfg.trig());
	ui->spinBox_2->setValue(cfg.fault());
	if (cfg.enable() == 1) {
		ui->checkBox->setCheckState(Qt::CheckState::Checked);
	} else {
		ui->checkBox->setTristate(Qt::CheckState::Unchecked);
	}
}
GratingJ GratingSettingWid::GetCfg()
{
	GratingJ cfg = {};
	cfg.id = ui->lineEdit->text();
	cfg.trig = ui->spinBox->value();
	cfg.fault = ui->spinBox_2->value();
	cfg.enable = ui->checkBox->checkState() == Qt::CheckState::Checked ? 1 : 0;
	return cfg;
}
